package com.epam.task.web.entity;

import com.epam.task.web.dao.impl.IEZakaz;

import java.util.List;

/**
 * User: zhunusbekova.arailym
 */
public class eZakaz implements IEZakaz {

    public Customer[] getAllUsers() {
        List<Customer> users = DataAccessLayer.getInstance().getAllUsers();
        return users.toArray(new Customer[users.size()]);
    }

    public Order[] getAllOrders() {
        List<Order> orders = DataAccessLayer.getInstance().getAllOrders();
        return orders.toArray(new Order[orders.size()]);
    }

    public void postOrder(String order, String username) {
        DataAccessLayer.getInstance().postOrder(username);
    }

    public Customer[] getUsersByStore() {
        List<Customer> onlineUsers = DataAccessLayer.getInstance().getUsersByStore();
        return onlineUsers.toArray(new Customer[onlineUsers.size()]);
    }

    public int login(String username, String password) {
        int loginResult = DataAccessLayer.getInstance().loginUser(username, password);
        return loginResult;
    }

    public int logout(String username, String password) {
        int logoutResult = DataAccessLayer.getInstance().logoutUser(username, password);
        return logoutResult;
    }
}
